<?php

namespace Modules\Ui\Admin;

use Arco\Facades\Arco;
use Arco\UI\Components\Row;
use Modules\System\Admin\Common;


class Index extends Common
{
    public function index(){
        $html = [];
        $rowHtml = Arco::row(function (Row $row){
            $row->column(8,"测试1");
            $row->column(8,"测试2");
            $row->column(8,"测试3");
        })->class("bg-gray-300 m-2 p-4 h-18")->gutter(10)->justify('center')->align('center');
        $code = <<<PHP
\$html[] = Arco::row(function (Row \$row){
    \$row->column(8,"测试1");
    \$row->column(8,"测试2");
    \$row->column(8,"测试3");
})->class("bg-gray-300 m-2 p-4 h-18")->gutter(10)->justify('center')->align('center');
PHP;
        $html[] = $rowHtml;
        $html[] = Arco::row(function (Row $row) use($code) {
            $row->column(24,Arco::preCode($code));
        });
        $html[] = Arco::collapse()->accordion(true)->defaultActiveKey([0,1,2])
            ->item("栅格布局","内布局")
            ->item("标题1","内容1")
            ->item("标题2","内容2");
        $html[] = Arco::div("测试这")->class("my-2 p-4 w-1/3 h-18 bg-gray-400");
        $html[] = Arco::button()->child("打开弹窗")->toggle();
        $html[] = Arco::modal("弹窗",Arco::preCode($code))->width(800)->visible();
//            ->ok(<<<JS
//console.log(data);
//JS)->onBeforeOk(<<<JS
//setTimeout(()=>{
//    done();
//},2000)
//return false;
//JS);
        $modal = Arco::modal("弹窗","弹窗内容")->visible("visible1");
//            ->ok(<<<JS
//data.visible = false;
//console.log(data);
//JS)->onBeforeOk(<<<JS
//setTimeout(()=>{
//    done();
//},2000)
//return false;
//JS);
        $html[] = Arco::button()->toggle("visible1")->addChild("打开弹窗")->addChild($modal);
//        $html[] = Arco::button()->click("()=>{toggleVisible(data,'visible1')}")->addChild("打开弹窗")->addChild($modal);

        $html[] = Arco::div("成功消息")
            ->name("a-button")
            ->attr("type","success")
            ->click(<<<JS
window.dialog.success({
    title: 'Success Notification',
    content: 'This is a success notification'
});
JS);
//        $html[] = Arco::button()->type("primary")->child("测试");
//        $html[] = Arco::div("打开新窗口")
//            ->name("a-button")
//            ->attr("type","primary")
//            ->click(<<<JS
//()=>{
//    const modal = window.vueApp._context.config.globalProperties.\$modal;
//    modal.open({
//        title:"弹窗",content:"内容",onBeforeOk:()=>{
//            return false;
//        },
//        onBeforeCancel:()=>{
//            return false;
//        }
//    })
//}
//JS);
        $html[] = Arco::icon("user")->size(12);
        $node = Arco::div()->name('app-layout')->child($html);
        $data = [];
        return Arco::node($node,$data)
                ->registerPrism()
                ->success();
    }
}
